<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
    "http://www.w3.org/TR/html4/loose.dtd">
<%@ include file="/base/pages/base.jsp" %>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>文件上传</title>    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<link href="<%=path%>/css/uploadify/default.css" rel="stylesheet" type="text/css" />
   	<link href="<%=path%>/css/uploadify/uploadify.css" rel="stylesheet" type="text/css" />
	<script type="text/javascript" src="<%=path%>/js/uploadify/swfobject.js"></script>
	<script type="text/javascript" src="<%=path%>/js/uploadify/jquery.uploadify.v2.1.0.min.js"></script>
	<script type="text/javascript">
	 jQuery(document).ready(init);
	 function init(){
	   jQuery("#uploadReport").uploadify({
           'uploader'       : '<%=path%>/js/uploadify/uploadify.swf',
           'script'         : "<%=path%>/uploadFiletoDB",
           'cancelImg'      : '<%=path%>/js/uploadify/cancel.png',
           'queueID'        : 'reportfileQueue',
           'fileDataName'   : 'uploadReport',	
           'method'         :'GET',	    
           'scriptData'	    :{'fileId':'78','projectId':'02','classType':'01'}, //${projectId}
           'auto'           : true,
           'multi'          : false,
           'onComplete'     : function(event,queueId,fileObj,response,data){
           					var arrayValue=response.split(",");
           					response="<div id='affix"+arrayValue[1]+"'><input type=hidden name='haverep'><a href='<%=path%>/uploadFile/downLoadAffix.action?docAffixId="+arrayValue[1]+"'>"+arrayValue[0]+"</a>&nbsp;&nbsp;<a href='#' onclick='javascript:removeAffix("+arrayValue[1]+")'><img src='<%=path%>/image/cross.gif' width='16' height='16' align='absmiddle'></a></div>";
           				   	jQuery('#uploadReportList').append(response);	                				   	
           				   },             				   
           'buttonImg'      : '<%=path%>/image/attach.gif',
           'width'		   : '16',
           'height'         : '16'
       });
     }
     function removeAffix(docAffixId){
      	 jQuery.ajax({
			url : '<%=path%>/uploadFile/removeAffix.action',
			type : 'post',
			data : "docAffixId=" + docAffixId,
			dataType : 'html',
			timeout : 1000,
			success : function(html) {			
				jQuery("#affix"+docAffixId).empty();
			}
		});
     }
	</script>
  </head>
  
  <body>
  <form name="add" method="post" >
   <table align="center">
    <tr><td> 
     上传文件：<input type="file" name="uploadReport" id="uploadReport" />
     </td><td>
    <c:forEach items="${reportAffixs}" varStatus="status" var="report">
  		<div id="affix${report.docAffixId}"><input type=hidden name='haverep'><a href="<%=path%>/uploadFile/downLoadAffix.action?docAffixId=${report.docAffixId}">${report.docAffixName}</a>&nbsp;&nbsp;
  		<a href='#' onclick='javascript:removeAffix(${report.docAffixId})'"><img src="<%=path%>/image/cross.gif" width="16" height="16" align="absmiddle" ></a></div>
  	</c:forEach>
    <div id="reportfileQueue"></div>
	<span id="uploadReportList"></span>
	</td></tr>
	</table><br>
	</form>
  </body>
</html>
